package team.pwy.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import team.pwy.interceptor.LoginInterceptor;

import java.util.List;

@Configuration
public class WebMVCConfig implements WebMvcConfigurer {

    @Bean
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor()).addPathPatterns("/user");
//                .excludePathPatterns("/plugins/**","/js/**","/css/**",
//                        "/imgs/**","/user/**","/movie/**","/html/activity.html"
//                    ,"/html/activity_child.html","/html/index.html","/html/login.html","/html/nav.html"
//                        ,"/html/seat.html","/html/session.html");
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(new HandlerArgsConfig());
    }
}
